#ifndef XMMPPROFILE_H
#define XMMPPROFILE_H

#include <qxmmp/lib/src/QXmppClient.h>

#include "cprofile.h"
#include "iprofile.h"

class ContactInfo;

class IXmppProfile : public IProfile
{
    Q_OBJECT
public:
    IXmppProfile(QObject * parent = 0);
    ~IXmppProfile() {}

    QString networkId() const;
    CProfile * createInstance(const CAuthInfo &authInfo);
};

class IVkontakteProfile : public IXmppProfile
{
    Q_OBJECT
public:
    IVkontakteProfile(QObject * parent = 0) : IXmppProfile(0) {}
    ~IVkontakteProfile() {}

    QString networkId() const;

    bool match(const CAuthInfo &authInfo);
    bool fillAuthInfo(CAuthInfo *authInfo);
};

//*********************************

class XmppProfile : public CProfile
{
    Q_OBJECT
public:
    explicit XmppProfile(const CAuthInfo &authInfo, IProfile *parent = 0);

    ContactInfo resolveUid(const QString &uid) const;

    void connectToNetwork();
    void disconnectFromNetwork();

    void sendMessage(const QString &message, const ContactInfo &to);

private slots:
    void clientConnected();
    void clientDisconnected();
    void clientError(QXmppClient::Error error);
    void clientVCardReceived();

    void clientMessageReceived(const QXmppMessage &message);

    void rosterReceived();
    void rosterChanged(const QString &bareJid);
    void presenceChanged(const QString &bareJid, const QString &resource);

private:
    void setPresence(ContactInfo * contact, const QString &uid);

    QXmppClient * m_client;
};

#endif // XMMPPROFILE_H
